url ='https://www.acwing.com/problem/content/description/798/'

n, m, q = map(int, input().split())

s = [[0] * (m + 1) for _ in range(n + 1)]

for i in range(1, n + 1):
    row = list(map(int, input().split()))
    for j in range(1, m + 1):
        s[i][j] = row[j - 1]

for i in range(1, n + 1):
    for j in range(1, m + 1):
        s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1]

for _ in range(q):
    x1, y1, x2, y2 = map(int, input().split())
    res = s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1]
    print(res)
